class MyCircularQueue {


    private int[] elem;
    private int front;
    private int rear;
    public MyCircularQueue(int k) {
        this.elem = new int[k];
    }

    public boolean enQueue(int value) {
        if(isFull()) {
            return false;
        }
        this.elem[rear] = value;
        rear = (rear+1)%this.elem.length;
        return true;
    }

    public boolean deQueue() {
        //1.空的 不能出
        if(isEmpty()){
            return false;
        }
        //2.不空 则保存对头元素 front后走
        int ret = Front();
        front = (front+1)%elem.length;
        return true;

    }

    public int Front() {
        //得到对头元素
        if(isEmpty()){
            return -1;
        }

        return this.elem[front];
    }

    public int Rear() {
        if(isEmpty()){
            return  -1;
        }
        int index = (rear == 0) ? (elem.length - 1):(rear -1) ;
        return elem[index ];

    }

    public boolean isEmpty() {
        return this.rear == this.front;

    }

    public boolean isFull() {
        if((this.rear + 1 )% this.elem.length == this.front){
            return true;
        }
        return false;

    }
}